//
//  GRUltimateModel.m
//  YC_GRice
//
//  Created by Feng Liu on 2018/9/26.
//  Copyright © 2018年 YeCai. All rights reserved.
//

#import "GRUltimateModel.h"
#import "GRStoreClassModel.h"

@implementation GRUltimateModel

-(NSMutableArray<GRUltimateShopModel *> *)storeList {
    if (!_storeList) {
        _storeList = [NSMutableArray array];
    }
    return _storeList;
}


- (BOOL)modelCustomTransformFromDictionary:(NSDictionary *)dic{    
    NSArray *categories = dic[@"categories"];
    if (Array(categories)) {
        NSMutableArray *categoryArr = [NSMutableArray array];
        NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
        for (NSDictionary *dic in categories) {
            GRStoreClassModel *model = [GRStoreClassModel yy_modelWithDictionary:dic];
            [dictionary setValue:model.icon forKey:model.name];
            [categoryArr addObject:model];
        }
        self.imgDictionary = dictionary;
        self.classList = categoryArr;
    }
    
    NSArray *storeArr = dic[@"onePayInfos"];
    if (Array(storeArr)) {
        NSMutableArray *storeList = [NSMutableArray array];
        for (NSDictionary *dic in storeArr) {
            GRUltimateShopModel *model = [GRUltimateShopModel yy_modelWithDictionary:dic];
            [storeList addObject:model];
        }
        self.storeList = storeList;
    }
    
    return YES;
}

+ (NSArray *)modelPropertyBlacklist {
    return @[@"categories",
                 @"onePayInfos"];
}

@end

@implementation GRUltimateShopModel

- (BOOL)modelCustomTransformFromDictionary:(NSDictionary *)dic{
    NSArray *coordinate = dic[@"coordinates"];
    self.coordinate = CLLocationCoordinate2DMake([coordinate.lastObject doubleValue], [coordinate.firstObject doubleValue]);
    return YES;
}

+ (NSArray *)modelPropertyBlacklist {
    return @[@"coordinates"];
}

-(NSString *)imageName {
    switch (self.categoryId) {
        case 1:
            return @"Home_22";
            break;
            
        case 2:
            return @"Home_24";
            break;

        case 3:
            return @"Home_19";
            break;

        case 4:
            return @"Home_21";
            break;

        case 5:
            return @"Home_23";
            break;

        case 6:
            return @"Home_18";
            break;

        case 46:
            return @"Home_26";
            break;

        case 48:
            return @"Home_25";
            break;

        case 49:
            return @"Home_20";
            break;

        default:
            return @"Home_26";
            break;
    }
}

@end
